package middleware

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"oa_kadia_link/utils"
)

func Logger() gin.HandlerFunc {
	return gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
		return fmt.Sprintf("[NEFU-OA] %s | %-15s | %-5s | %-10s | %d | %s | %s | %s\n",
			param.TimeStamp.Format("2006-01-02 15:04:05"),
			utils.GetRealIP(param.Request),
			param.Method,
			param.Path,
			param.StatusCode,
			param.Latency,
			param.Request.Proto,
			param.ErrorMessage,
		)
	})
}
